angular.module('app', ['ngAnimate'])
	.controller('GuessTheNumberController', GuessTheNumberController);
	function GuessTheNumberController($scope) {
		$scope.verifyGuess = function () {
			if( $scope.guess > $scope.maxNumber){
				alert("不能超过最大数: " + $scope.maxNumber);
				return;
			}
			$scope.deviation = $scope.original - $scope.guess;
			$scope.noOfTries = $scope.noOfTries + 1;
		};

		//初始化 
		$scope.initializeGame = function() {
			// 最大数
			$scope.maxNumber = 1000;
			// 猜数次数
			$scope.noOfTries = 0;
			// 答案
			$scope.original = Math.floor((Math.random() * 1000) + 1);
			// 猜的数
			$scope.guess = null;
			// 偏差数
			$scope.deviation = null;
		};

		$scope.initializeGame();
	}